package cn.itsource.pethome.org.mapper;

import cn.hutool.core.collection.CollectionUtil;
import cn.itsource.pethome.base.superr.MyBaseMapper;
import cn.itsource.pethome.org.domain.Shop;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

public interface ShopMapper extends MyBaseMapper<Shop> {

    default Class<Shop> getTClass(){
        return Shop.class;
    };

    default Boolean findByName(String name){
        //1.创建example
        Example example = new Example(getTClass());
        //2.获取条件对象
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("name",name);
        List<Shop> shops = this.selectByExample(example);
        if (CollectionUtil.isEmpty(shops)){
            return Boolean.FALSE;
        }else {

            return Boolean.TRUE;
        }
    };
}
